package com.seadragon.app.ksr.model;

import java.io.Serializable;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@SuppressWarnings("serial")
@Entity
@Table(name = "BUSINESS", schema="STAGING")
public class Business implements Serializable {
	@Id
	@Column(name = "ID")
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "BUSINESSIDSEQ")
	@SequenceGenerator(name = "BUSINESSIDSEQ", sequenceName = "STAGING.BUSINESS_ID_SEQ", schema="STAGING")	
	private long id;

//	@Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO)
	@Column(name = "business_name")
	private String businessName;

	@Column(name = "business_type")
	private String businessType;

//	@IndexedEmbedded
	@ManyToMany(cascade = CascadeType.MERGE, fetch=FetchType.EAGER)
	@JoinTable(schema = "STAGING", name = "BUSINESS_CATEGORY_MAP", joinColumns = { @JoinColumn(table = "BUSINESS", name = "BUSINESS_ID", referencedColumnName = "ID") }, inverseJoinColumns = { @JoinColumn(table = "CATEGORY", name = "CATEGORY_ID", referencedColumnName = "ID") })
	private Set<Category> categories;

	@Column(name = "description", length = 2048)
//	@Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO)
	private String description;

	@Column(name = "specialty")
//	@Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO)
	private String specialty;

	@Column(name = "email_address")
	private String emailAddress;

	@Column(name = "phone_number")
	private String phoneNumber;

	@Column(name = "PASSWORD")
	private String password;

	@Column(name = "web_site")
	private String webSite;

	@OneToMany(mappedBy = "business", cascade = CascadeType.ALL, orphanRemoval = true)
//	@ContainedIn
	private List<Office> offices;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getBusinessName() {
		return businessName;
	}

	public void setBusinessName(String businessName) {
		this.businessName = businessName;
	}

	public String getBusinessType() {
		return businessType;
	}

	public void setBusinessType(String businessType) {
		this.businessType = businessType;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getSpecialty() {
		return specialty;
	}

	public void setSpecialty(String specialty) {
		this.specialty = specialty;
	}

	public String getEmailAddress() {
		return emailAddress;
	}

	public void setEmailAddress(String emailAddress) {
		this.emailAddress = emailAddress;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getWebSite() {
		return webSite;
	}

	public void setWebSite(String webSite) {
		this.webSite = webSite;
	}

	public Set<Category> getCategories() {
		return categories;
	}

	public void setCategories(Set<Category> categories) {
		this.categories = categories;
	}

	public List<Office> getOffices() {
		return offices;
	}

	public void setOffices(List<Office> offices) {
		this.offices = offices;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
}
